// new standard header
#ifndef _NEW_
#define _NEW_
#include <exception>

 #if __GNUC__ < 3
_X_STD_BEGIN
 #else /* __GNUC__ < 3 */
namespace std {
 #endif /* __GNUC__ < 3 */

		// CLASS bad_alloc
class bad_alloc
	: public _XSTD exception
	{	// base of all bad allocation exceptions
public:
 #if __EDG__ || defined(__SUNPRO_CC)
	bad_alloc(const char *_Message = "bad allocation") _THROW0()
		: exception(_Message)
		{	// construct from message string
		}

 #elif __MINGW32__ && __GNUC__ == 4 && 9 <= __GNUC_MINOR__
	bad_alloc() _THROW0()
		{	// construct with no message string
		}

	bad_alloc(const char *_Message) _THROW0()
		{	// construct from message string
		}

	virtual const char *what() const _THROW0();

	virtual ~bad_alloc() _NOEXCEPT;

 #else /* __EDG__ etc. */
	bad_alloc() _THROW0()
		{	// construct with no message string
		}

	bad_alloc(const char *_Message) _THROW0()
		{	// construct from message string
		}

	virtual const char *what() const _THROW0()
		{	// report a bad allocation
		return ("bad allocation");
		}
 #endif /* __EDG__ etc. */

//	virtual ~bad_alloc() _NOEXCEPT
//		{	// destroy the object
//		}

 #if _HAS_EXCEPTIONS

 #else /* _HAS_EXCEPTIONS */
protected:
	virtual void _Doraise() const
		{	// perform class-specific exception handling
		_RAISE(*this);
		}
 #endif /* _HAS_EXCEPTIONS */
	};

 #if _HAS_CPP0X
		// CLASS bad_array_new_length
class bad_array_new_length
	: public bad_alloc
	{	// bad array new exception
public:
	bad_array_new_length() _THROW0()
		: bad_alloc("bad array new length")
		{	// default construct
		}
	};
 #endif /* _HAS_CPP0X */

 #if __GNUC__ < 3
_X_STD_END

 #else /* __GNUC__ < 3 */
} /* namespace std */

 #if _HAS_NAMESPACE

 #else /* _HAS_NAMESPACE */
using _STD bad_alloc;
 #endif /* _HAS_NAMESPACE */

 #endif /* __GNUC__ < 3 */

_STD_BEGIN
		// SUPPORT TYPES
typedef void (_CDECL *new_handler)();	// handler for operator new failures

struct nothrow_t
	{	// placement new tag type to suppress exceptions
	};

extern _CRTIMP2 const nothrow_t nothrow;	// constant for placement new tag

		// FUNCTION AND OBJECT DECLARATIONS
_CRTIMP2 new_handler _CDECL get_new_handler()
	_NOEXCEPT;	// get new handler
_CRTIMP2 new_handler _CDECL set_new_handler(new_handler)
	_THROW0();	// establish alternate new handler
_STD_END

		// new AND delete DECLARATIONS (NB: NOT IN std)

 #if defined(__SUNPRO_CC)
void _CDECL operator delete(void *) throw();	// delete allocated storage

void *_CDECL operator new(_CSTD size_t);
//	throw(_STD bad_alloc);	// allocate or throw exception

 #else /* defined(__SUNPRO_CC) */
void _CDECL operator delete(void *);	// delete allocated storage

 #if _HAS_CPP1X
void *_CDECL operator new(_CSTD size_t);

 #else /* _HAS_CPP1X */
void *_CDECL operator new(_CSTD size_t)
	_THROWS(_XSTD bad_alloc);	// allocate or throw exception
 #endif /* _HAS_CPP1X */

 #endif /* defined(__SUNPRO_CC) */

void *_CDECL operator new(_CSTD size_t, const _STD nothrow_t&)
	_THROW0();	// allocate or return null pointer

inline void *_CDECL operator new(_CSTD size_t, void *_Where) _THROW0()
	{	// construct with placement at _Where
	return (_Where);
	}

 #if defined(__SUNPRO_CC)
void _CDECL operator delete[](void *) throw();	// delete allocated array

void *_CDECL operator new[](_CSTD size_t);
//	throw(_STD bad_alloc);	// allocate array or throw exception

 #else /* defined(__SUNPRO_CC) */
void _CDECL operator delete[](void *);	// delete allocated array

 #if _HAS_CPP1X
void *_CDECL operator new[](_CSTD size_t);

 #else /* _HAS_CPP1X */
void *_CDECL operator new[](_CSTD size_t)
	_THROWS(_XSTD bad_alloc);	// allocate or throw exception
 #endif /* _HAS_CPP1X */

 #endif /* defined(__SUNPRO_CC) */

void *_CDECL operator new[](_CSTD size_t, const _STD nothrow_t&)
	_THROW0();	// allocate array or return null pointer

inline void *_CDECL operator new[](_CSTD size_t, void *_Where) _THROW0()
	{	// construct array with placement at _Where
	return (_Where);
	}

void _CDECL operator delete(void *, const _STD nothrow_t&)
	_THROW0();	// delete if nothrow new fails -- REPLACEABLE

void _CDECL operator delete[](void *, const _STD nothrow_t&)
	_THROW0();	// delete if nothrow array new fails -- REPLACEABLE

void _CDECL operator delete(void *, void *) _THROW0();
//	{	// delete if placement new fails
//	}

void _CDECL operator delete[](void *, void *) _THROW0();
//	{	// delete if placement array new fails
//	}
#endif /* _NEW_ */

/*
 * Copyright (c) by P.J. Plauger. All rights reserved.
 * Consult your license regarding permissions and restrictions.
V6.50:1422 */
